extends ../layout

block content
    div.container.height.personal-task
        div
            div.input-group.has-success(style='margin-top:20px;')
                div.input-group-addon(style='font-size: 20px;') +
                input#taskAddInput.task-add-input.form-control

            div.task-by-user
                h3 董鹏飞
                each task in taskList
                    div.task-list-container
                        div.task-container.checkbox
                            input.isComplete(type='checkbox', data-task-id='#{task.id}')
                            span.task #{task.task_name}
                            span.create-time #{moment(task.create_time).format('YYYY-MM-DD HH:mm:ss')}

    script.
        $(function () {
            $('#task-management').addClass('select-active')

            $('#taskAddInput').focus()
                .keyup(function (e) {
                if (e.keyCode == 13) {  //回车'
                    var taskName = $('#taskAddInput').val();
                    if (taskName) {
                        $.post('/personalTask/save', {taskName: taskName}, function (result) {
                            location.reload();
                        });
                    }
                }
                });

            $('.isComplete').click(function () {
                var isChecked = $("#cb1").attr("checked");
                if (!isChecked) {
                    var taskId = $(this).attr('data-task-id');
                    $.post('/personalTask/complete/' + taskId, function (result) {
                        location.reload();
                    });
                }
            });
        });







